<template>
	<view class="buttom-bar" :class="{'buttom-bar-border': border, 'buttom-bar-round': round}" :style="{'width': Width, 'height': Height, 'font-size': fontSize, 'border-color': color, 'color': color, 'background': background}" @click="onClick">
		<view v-if="iconName" class="buttom-icon"><icon-bar :name="iconName" :size="size"></icon-bar></view>
		<view>{{title}}</view>
	</view>
</template>

<script>
	export default {
		name: 'ButtomBar',
		title: '按钮',
		props: {
			title: {
				type: String,
				default: '确定'
			},
			width: {
				type: [Number, String],
				default: '100%'
				
			},
			height: {
				type: [Number, String],
				default: 50
			},
			size: {
				type: Number,
				default: 24
			},
			color: {
				type: String,
				default: '#666'
			},
			iconName: {
				type:String,
				default: ''
			},
			background: {
				type: String,
				default: ''
			},
			border: {
				type: Boolean,
				default: true
			},
			round: {
				type: Boolean,
				default: true
			},
			url: {
				type: String,
				default: ''
			},
			openType: {
				type: String,
				default: 'navigateTo'
			}
		},
		computed: {
			Width() {
				return typeof this.width == 'number'?`${this.width}rpx` : this.width
			},
			Height() {
				return typeof this.height == 'number'?`${this.height}rpx` : this.height
			},
			fontSize() {
				return `${this.size}rpx`
			}
		},
		methods: {
			onClick() {
				if(this.url){
					uni[this.openType]({
					    url: this.url
					});
					return false
				}
				this.$emit('click')
			}
		},
		data() {
			return {
				
			};
		}
	}
</script>

<style lang="scss" scoped>
	@import  '@/uni.scss';
	.buttom-bar{
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
	}
	.buttom-icon{
		margin-right: 10upx;
	}
	.buttom-bar-border{
		border: solid 2upx;
	}
	.buttom-bar-round{
		border-radius: 10upx;
	}
</style>
